#include<iostream>
#include<cmath>
#include <iomanip>
#include"Mortgage.h"
using namespace std;
	
double rate;
int n;
double pmt = 0;
double pv;
double fv;


void Mortgage::Instructions()
{	
	 Annuity::setValues(rate, n, 0 ,pv,fv);
}

double Mortgage::Ammortization()const																			// This is to calculation constant monthly payment
{
	return getPV() / ((((1-1/ pow(1+getR(), getN()*12))/getR()))*(1+getR()));									// pmt = PV / ((1 - (1+R)^-N)/R)
}

void Mortgage::printAmmo()
{
	cout <<"Base on your entries of: " << endl;
	cout <<"Loan amt: $" << getPV() << endl;
	cout <<"Monthly norminal Interest Rate(APR/12): " << setprecision(2) << getR() << "%" << endl;
	cout <<"Mortgage type: " << getN() << " year mortgage"  << endl;
	cout <<"Your monthly mortgage payment will be: $" << setprecision(5) << Ammortization() << endl;
}

Mortgage::Mortgage()
{

}